windows container
参考
windowsでビルドする際にローカルwindowsでdockerを有効化する
windows のdockerはバックエンドがdefaultでWSL2である
windows containerをうごかすにはWSL2バックエンドでは動かない
windows backendにする
事前にHyper-Vとcontainersの機能を有効化しておくこと
code:powershell
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
windows containerでのDockerfile
windows contaienrはホストよりも古い環境でも動作はする
build時は--platformを指定しないとマニフェストがなくてimage downloadできないので注意
docker build --platform windows/amd64 ./
builderkitがwindowsに対応してないのでbuildxは使えない
chocolatyをインストール
code:chocolaty install
コンテナイメージログイン
docker run -it --rm <image> powershell
SSH server
code:powersherll
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22